<?php
class Feed
{
	/* This class will interface directly with the MySQL database, and provide methods for
	 * accessing a user's feed, and to publish items to the feed.
	 */

	private $UID,
			$lastUpdated,
			$items;

	public function __construct($UID)
	{
		$sql = "SELECT * FROM feeditems WHERE id=" . $UID;
        $result = mysql_query($sql);
        $row = mysql_fetch_array($result, MYSQL_ASSOC)); 
		$this->UID = $UID;
		//get users feed from DB
	}
	public function getItems($limit)
	{
		$sql = "SELECT * FROM feeditems WHERE userid= " . $UID . " ORDER BY timetstamp desc LIMIT " . $limit;
		//return $limit number of items from the feed
	}
	public function lastUpdated()
	{
		$sql = "SELECT timestamp FROM feeditems ORDER BY desc LIMIT 1";
        $result = mysql_query($sql);
        $row = mysql_fetch_array($result, MYSQL_ASSOC)); 
		$this->lastUpdated = $row['timestamp'];
		return $lastUpdated;
	}
	public function publishItem($item)
	{
		$sql = "INSERT INTO feeditems (title, content, imageurl, timestamp)
		VALUES(" . $item->getTitle() . ", " . $item->getContent() . ", " . $item->getImageURL() "," . time() . ")";
		mysql_query($sql);
		//add new item, update stats
	}
}
?>